/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package groupe;

import javax.swing.*;
import org.w3c.dom.Element;
import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ResourceMap;
/**
 *
 * @author Ter Murga Victor
 */
public class GroupeProperties extends JDialog{
    private JButton closeButton;

    public GroupeProperties(String url) {
        //super(parent);
        initComponents(url);
        getRootPane().setDefaultButton(closeButton);
    }

    @Action
    public void closeBox() {
        dispose();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents(String url) {
        Element rootEl = null;
        try {
            rootEl = Utility.getElement(url);
        } catch (Exception ex) {
            System.out.println("Erreur pendant la conversion: "+ex);
        }

        closeButton = new javax.swing.JButton();
        JLabel appTitleLabel = new JLabel();
        JLabel structureLabel = new JLabel();
        JLabel profilStructureLabel = new JLabel();
        JLabel creatorLabel = new JLabel();
        JLabel profilCreatorLabel = new JLabel();
        JLabel locationLabel = new JLabel();
        JLabel profilLocationLabel = new JLabel();
        JLabel createdLabel = new JLabel();
        JLabel profilCreatedLabel = new JLabel();
        JLabel modifiedLabel = new JLabel();
        JLabel profilModifiedLabel = new JLabel();
        //JLabel appDescLabel = new JLabel();
        JLabel imageLabel = new JLabel();

        ResourceMap resourceMap = Application.getInstance(groupe.App.class).getContext().getResourceMap(GroupeProperties.class);
        setTitle(resourceMap.getString("title")); // NOI18N
        setModal(true);
        setName("aboutBox"); // NOI18N
        setResizable(false);

        ActionMap actionMap = Application.getInstance(groupe.App.class).getContext().getActionMap(GroupeProperties.class, this);
        closeButton.setAction(actionMap.get("closeBox")); // NOI18N
        closeButton.setName("closeButton"); // NOI18N

        appTitleLabel.setFont(appTitleLabel.getFont().deriveFont(appTitleLabel.getFont().getStyle() | java.awt.Font.BOLD, appTitleLabel.getFont().getSize()+4));
        appTitleLabel.setText(rootEl.getAttribute("nom_eleve")+" "+rootEl.getAttribute("prenom_eleve")); // NOI18N
        appTitleLabel.setName("appTitleLabel"); // NOI18N

        structureLabel.setFont(structureLabel.getFont().deriveFont(structureLabel.getFont().getStyle() | java.awt.Font.BOLD));
        structureLabel.setText(resourceMap.getString("structure.text")); // NOI18N
        structureLabel.setName("structureLabel"); // NOI18N

        profilStructureLabel.setText(rootEl.getAttribute("nom")); // NOI18N
        profilStructureLabel.setName("profilStructureLabel"); // NOI18N

        creatorLabel.setFont(creatorLabel.getFont().deriveFont(creatorLabel.getFont().getStyle() | java.awt.Font.BOLD));
        creatorLabel.setText(resourceMap.getString("creator.text")); // NOI18N
        creatorLabel.setName("creatorLabel"); // NOI18N

        profilCreatorLabel.setText(rootEl.getAttribute("createur")); // NOI18N
        profilCreatorLabel.setName("profilCreatorLabel"); // NOI18N

        locationLabel.setFont(locationLabel.getFont().deriveFont(locationLabel.getFont().getStyle() | java.awt.Font.BOLD));
        locationLabel.setText(resourceMap.getString("location.text")); // NOI18N
        locationLabel.setName("locationLabel"); // NOI18N

        profilLocationLabel.setText(url); // NOI18N
        profilLocationLabel.setName("profilLocationLabel"); // NOI18N

        createdLabel.setFont(createdLabel.getFont().deriveFont(createdLabel.getFont().getStyle() | java.awt.Font.BOLD));
        createdLabel.setText(resourceMap.getString("created.text")); // NOI18N
        createdLabel.setName("createdLabel"); // NOI18N

        profilCreatedLabel.setText(rootEl.getAttribute("date_creation")); // NOI18N
        profilCreatedLabel.setName("profilCreatedLabel"); // NOI18N

        modifiedLabel.setFont(modifiedLabel.getFont().deriveFont(modifiedLabel.getFont().getStyle() | java.awt.Font.BOLD));
        modifiedLabel.setText(resourceMap.getString("modified.text")); // NOI18N
        modifiedLabel.setName("modifiedLabel"); // NOI18N

        profilModifiedLabel.setText(rootEl.getAttribute("date_derniere_modif")); // NOI18N
        profilModifiedLabel.setName("profilModifiedLabel"); // NOI18N

        /*appDescLabel.setText(resourceMap.getString("appDescLabel.text")); // NOI18N
        appDescLabel.setName("appDescLabel"); // NOI18N*/

        imageLabel.setIcon(resourceMap.getIcon("imageLabel.icon")); // NOI18N
        imageLabel.setName("imageLabel"); // NOI18N


        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(imageLabel)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(structureLabel)
                            .addComponent(creatorLabel)
                            .addComponent(locationLabel)
                            .addComponent(createdLabel)
                            .addComponent(modifiedLabel))
                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(profilStructureLabel)
                            .addComponent(profilCreatorLabel)
                            .addComponent(profilLocationLabel)
                            .addComponent(profilCreatedLabel)
                            .addComponent(profilModifiedLabel)))
                    .addComponent(appTitleLabel, GroupLayout.Alignment.LEADING)
                    //.addComponent(appDescLabel, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
                    .addComponent(closeButton))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(imageLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(appTitleLabel)
                /*.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(appDescLabel)*/
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(structureLabel)
                    .addComponent(profilStructureLabel))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(creatorLabel)
                    .addComponent(profilCreatorLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(locationLabel)
                    .addComponent(profilLocationLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(createdLabel)
                    .addComponent(profilCreatedLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(modifiedLabel)
                    .addComponent(profilModifiedLabel))
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addComponent(closeButton)
                .addContainerGap())
        );

        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        pack();
    }

}
